package cn.myfirefly.moming.common.dao;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import cn.myfirefly.moming.common.dao.mapper.UserRoleMapper;
import cn.myfirefly.moming.common.entity.MMUserRole;
import cn.myfirefly.moming.common.model.RoleDto;
import cn.myfirefly.core.BaseDao;

@Repository
public class UserRoleDao extends BaseDao<MMUserRole>{
	
	@Autowired
	private UserRoleMapper roleMapper;
	
	public void delByUserSn(Integer userSn) {
		Session session = getCurrentSession();
		Query query = session.createQuery(" delete from MMUserRole  where userSn = ? " );
		query.setInteger(0, userSn);
		query.executeUpdate();
	}
	
	public List<RoleDto> getRoles(Integer userSn) {
		List<RoleDto> results = roleMapper.getRoles(userSn);
		return results;
	}
}
